#
# Default configuration file contents
#

from ConfigParser import SafeConfigParser
from error import FgsProxyError

class FgsConfigParser(SafeConfigParser):
    def check_fields(self, errorfunc, *fields):
        errmsg = []
        for field in fields:
            if not self.has_option(*field):
                errmsg.append("Configuration file is missing the required"+
                              " '%s' option in section '%s'" % field)
        if len(errmsg) > 0:
            errorfunc(*errmsg)

    def check_failure_exception(self, *errmsg):
        raise FgsProxyError('\n'.join(errmsg))

config_data = """##
## General configuration for the proxy
##
[proxy]

# The name of this proxy. This is used for cosmetic purposes only.
name = My Proxy

# Which connector to load for communication with the backend.
backend = xmlrpc

# The proxy forks into the background if this is 'yes'.  Otherwise, it
# remains attached to the console that invoked it.
daemonize = yes


##
## Configuration for the XML-RPC backend connector.
##
[backend:xmlrpc]

# The URL of the FGS backend to connect to.  Usually, this ends in
# '/RPC2.php'.
url = http://your.server.net/fgs/RPC2.php

# The key assigned to the proxy in the backend.  This is equivalent to
# the proxy's 'login' on the backend.
key = 00000000000000000000000000000000

# The associated password for registration in the proxy.
password = bleh


##
## Configuration of logging
##
[logging]

# The name of the log file.  The path can be absolute, or relative to
# the directory where the proxy is launched.  The special value
# '@console', valid only if the proxy is not running as a daemon, logs
# to the standard out of the program.
logfile = fgs-proxy.log

# The logging level to use.  It can be one of critical, error,
# warning, info, debug, fulldebug.  Any messages less important than
# the given level will not be logged.  The most verbose level,
# fulldebug, is equivalent to debug, except that the debugging
# information for the Twisted engine is also displayed.
level = info


##
## Configuration for the SSH administration console
##
[ssh]

# Set to 'yes' to enable the SSH admin console.
enable = yes

# The files containing the server public and private keys.  If either
# of these do not exist, both keys will be regenerated when the proxy
# starts.
public_key = proxy.pub
private_key = proxy.key

# The file containing the usernames and passwords authorized for
# login.  This file will NOT be created for you, but can be built with
# the proxy_htpasswd.py utility script.
passwd_file = proxy.auth

# The file containing the Message of the Day.  It can include some
# replacement strings:
#
# %(name)s : The configured proxy name
#
motd_file = proxy.motd
"""

motd_data = """
 ______ _____  _____       ___        __
|  ____/ ____|/ ____|     / _ \      /_ |
| |__ | |  __| (___      | | | |      | |
|  __|| | |_ |\___ \     | | | |      | |
| |   | |__| |____) |    | |_| |  _   | |
|_|    \_____|_____/      \___/  (_)  |_|
       Free gaming for free people
           http://freegs.net/

 =======================================
  Welcome to %(name)s
 =======================================
"""
